package com.softeem.work.w5;

public abstract class Tank {
    //攻击力
    private int atk;
    //生命值
    private int hp;
    //防御值
    private int def;

    public Tank() {
    }

    public Tank(int atk, int hp, int def) {
        this.atk = atk;
        this.hp = hp;
        this.def = def;
    }

    public int getAtk() {
        return atk;
    }

    public void setAtk(int atk) {
        this.atk = atk;
    }

    public int getHp() {
        return hp;
    }

    public void setHp(int hp) {
        this.hp = hp;
    }

    public int getDef() {
        return def;
    }

    public void setDef(int def) {
        this.def = def;
    }

    @Override
    public String toString() {
        return "Tank{" +
                "atk=" + atk +
                ", hp=" + hp +
                ", def=" + def +
                '}';
    }


    //射击
    public void shoot(Tank t) {
        t.setHp(t.getHp() - this.atk);
        System.out.println("当前坦克剩余血量：" + t.getHp());
    }

    //移动
    public void move() {
        System.out.println("坦克移动");
    }
    //死亡
    public void die() {
        System.out.println("坦克死亡");
    }

    public abstract void work();


}
